package hu;

import java.util.*;

public class hu63 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] ch = sc.nextLine().toCharArray();
        int n = sc.nextInt();
        int max = 0;
        int t = 0;
        for (int i = 0; i <= ch.length - n; i++) {
            int sum = 0;
            for (int j = i; j < i + n; j++) {
                if(ch[j] == 'G' || ch[j] == 'C')
                    sum++;
            }
            if(sum > max){
                max = sum;
                t = i;
            }
        }
        for (int i = t; i < t + n; i++) {
            System.out.print(ch[i]);
        }
    }
}
